﻿/* 内层图片滚动切换 */
jQuery(".slideGroup .slideBoxt").slide({ mainCell:"ul",vis:1,prevCell:".sPrev",nextCell:".sNext",effect:"leftLoop"});
jQuery(".slideGroup .slideBoxtt").slide({ mainCell:"ul",vis:5,prevCell:".sPrev",nextCell:".sNext",effect:"leftLoop"});
/* 外层tab切换 */
jQuery(".slideGroup").slide({titCell:".parHd li",mainCell:".parBd"});

jQuery(".slideGroup .slideBoxt").hover(function(){ jQuery(this).find(".sPrev,.sNext").stop(true,true).fadeTo("show",0.5) },function(){jQuery(this).find(".sPrev,.sNext").fadeOut() });	

jQuery(".fullSlide").hover(function(){ jQuery(this).find(".prev,.next.htm"/*tpa=lbagri/statics/js/.prev,.next*/).stop(true,true).fadeTo("show",0.5) },function(){jQuery(this).find(".prev,.next.htm"/*tpa=lbagri/statics/js/.prev,.next*/).fadeOut() });	
			
jQuery(".fullSlide").slide({ titCell:".hd ul", mainCell:".bd ul", effect:"fold", interTime:10000,autoPlay:true, autoPage:true, trigger:"click",startFun:function(i){var timer = jQuery(".fullSlide .timer");
			timer.stop(true,true).animate({ "width":"0%" },0).animate({ "width":"100%" },10000);var curLi = jQuery(".fullSlide .bd li").eq(i);if( !!curLi.attr("_src") ){curLi.css("background-image",curLi.attr("_src")).removeAttr("_src") 				}}});	

jQuery(".nav").slide({ type:"menu",  titCell:".m", targetCell:".sub",effect:"slideDown", delayTime:300, triggerTime:0,defaultPlay:false,returnDefault:true  });
jQuery(".slideTxtBox").slide({effect:"leftLoop",autoPlay:true});
/* 视频滚动切换 */
jQuery("#tabRank li").hover(function(){ jQuery(this).addClass("on").siblings().removeClass("on")},function(){ });		
jQuery("#tabRank").slide({ titCell:"dt h3", mainCell:"dd",autoPlay:false,effect:"left",delayTime:300 });	

jQuery(".slideTxtBoxlm").slide({effect:"leftLoop",autoPlay:false});

jQuery(".slideTxtBoxhj").slide({titCell:".hd li", autoPlay:false,effect:"left",delayTime:300});
jQuery(".slideTxtBoxlink").slide({effect:"leftLoop",autoPlay:false});
 function trim(str){return str.replace(/(^\s*)|(\s*$)/g,"");}
function CheckPost()
{
if (trim(myform.keyword.value)==""){alert("请填写您要搜索的内容！");myform.keyword.focus();return false;}
}
/* 栏目图片遮罩 */
// 修正FF浏览器兼容
function getOffset(e) {
    var target = e.target;
    if (target.offsetLeft == undefined) {
        target = target.parentNode;
    }
    var pageCoord = getPageCoord(target);
    var eventCoord = {
        x: window.pageXOffset + e.clientX,
        y: window.pageYOffset + e.clientY
    };
    var offset = {
        offsetX: eventCoord.x - pageCoord.x,
        offsetY: eventCoord.y - pageCoord.y
    };
    return offset;
}

function getPageCoord(element) {
    var coord = {
        x: 0,
        y: 0
    };
    while (element) {
        coord.x += element.offsetLeft;
        coord.y += element.offsetTop;
        element = element.offsetParent;
    }
    return coord;
}


$(document).ready(function(){	
	//底部浮动
	$(window).scroll(function(){
	var scrollTop = $(this).scrollTop();
　　var scrollHeight = $(document).height();
　　var windowHeight = $(this).height();
		if (scrollHeight-(scrollTop+windowHeight)>517) {$(".fotfl").fadeIn()}else{$(".fotfl").fadeOut()};
		});
	
	$(".items .img.htm"/*tpa=lbagri/statics/js/.items .img*/).hover(function(e){
		
		var _this  = $(this), //闭包
		_desc  = _this.find(".desc").stop(true),
		width  = _this.width(), //取得元素宽
		height = _this.height(), //取得元素高
		left   = (e.offsetX == undefined) ? getOffset(e).offsetX : e.offsetX, //从鼠标位置，得到左边界，利用修正ff兼容的方法
		top    = (e.offsetY == undefined) ? getOffset(e).offsetY : e.offsetY, //得到上边界
		right  = width - left, //计算出右边界
		bottom = height - top, //计算出下边界
		rect   = {}, //坐标对象，用于执行对应方法。
		_min   = Math.min(left, top, right, bottom), //得到最小值
		_out   = e.type == "mouseleave", //是否是离开事件
		spos   = {}; //起始位置
	
		rect[left] = function (epos){ //鼠从标左侧进入和离开事件
			spos = {"left": -width, "top": 0};
			if(_out){
				_desc.animate(spos, "fast"); //从左侧离开
			}else{
				_desc.css(spos).animate(epos, "fast"); //从左侧进入
			}
		};
	
		rect[top] = function (epos) { //鼠从标上边界进入和离开事件
			spos = {"top": -height, "left": 0};
			if(_out){
				_desc.animate(spos, "fast"); //从上面离开
			}else{
				_desc.css(spos).animate(epos, "fast"); //从上面进入
			}
		};
	
		rect[right] = function (epos){ //鼠从标右侧进入和离开事件
			spos = {"left": left,"top": 0};
			if(_out){
				_desc.animate(spos, "fast"); //从右侧成离开
			}else{
				_desc.css(spos).animate(epos, "fast"); //从右侧进入
			}
		};
	
		rect[bottom] = function (epos){ //鼠从标下边界进入和离开事件
			spos = {"top": height, "left": 0};
			if(_out){
				_desc.animate(spos, "fast"); //从底部离开
			}else{
				_desc.css(spos).animate(epos, "fast"); //从底部进入
			}
		};
	
		rect[_min]({"left":0, "top":0}); // 执行对应边界 进入/离开 的方法
	
	});

});


//手风琴
jQuery(".pdby_3_1").slide({titCell:".tit",triggerTime:0,trigger:"click",autoPlay:false});

//折叠效果
jQuery(".sideMenu").slide({titCell:"h3", targetCell:"ul",defaultIndex:1,effect:"slideDown",delayTime:300,trigger:"click",returnDefault:true});

